#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>

int main()
{
    pid_t id = fork();
    if(id == 0)
    {
        printf("我是一个紫禁城");
        //execl("/usr/bin/ls","ls","-l","-a",NULL);
        char *args[] = {"ls", "-l", NULL}; // 参数数组，以NULL结尾
        execvp("ls",args);
        printf("exec success\n");
    }else{
         pid_t rid = waitpid(-1, NULL, 0);
        if(rid > 0)
        {
            printf("wait success, rid: %d\n", rid);
        }
    }
    return 0;
}